package com.zb.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjNetworkSet;
import com.zb.enums.SystemSetEnum;
import com.zb.mapper.ZjNetworkSetMapper;
import com.zb.service.ZjNetworkInviteCodeSetService;
import com.zb.service.ZjNetworkSetService;
import com.zb.vo.NetworkSetVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * <p>
 * 网点设置表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-07-25
 */
@Service
public class ZjNetworkSetServiceImpl extends ServiceImpl<ZjNetworkSetMapper, ZjNetworkSet> implements ZjNetworkSetService {
    @Resource
    private ZjNetworkInviteCodeSetService networkInviteCodeSetService;

    // 初始化 或 恢复初始化网点设置
    @Override
    public void initOrRestoreDefaulNetworkSet(Long custAccId) {
        ZjNetworkSet networkSet = new ZjNetworkSet();
        networkSet.setId(custAccId);
        networkSet.setSectorise(1);
        this.saveOrUpdate(networkSet);
        networkInviteCodeSetService.initOrRestoreDefaulNetworkSet(custAccId);
    }

    // 获取服务区域设置
    @Override
    public NetworkSetVo getNetworkSet(Long custAccId) {
        ZjNetworkSet networkSet = this.getById(custAccId);
        return NetworkSetVo.beanToVo(networkSet);
    }

    // 保存服务区域设置
    @Override
    public void saveNetworkSet(NetworkSetVo networkSetVo) {
        ZjNetworkSet networkSet = NetworkSetVo.voToBean(networkSetVo);
        this.updateById(networkSet);
    }

}
